<?php

$sql = "
select 
		TABLE_NAME, 
		ORDINAL_POSITION,
		COLUMN_NAME,
		'' as COLUMN_COMMENT, 
		ucase(DATA_TYPE) DATA_TYPE, 
		COLUMN_TYPE,
		case 
--		   when DATA_TYPE = 'int' then concat('(', NUMERIC_PRECISION,',',NUMERIC_SCALE,')')
		   when DATA_TYPE = 'text' then ''
		   ELSE CHARACTER_MAXIMUM_LENGTH
		end					AS DATA_LENGTH,
		NUMERIC_PRECISION	AS DATA_PREC,
		NUMERIC_SCALE		AS DATA_SCALE,
		CASE 
			WHEN IS_NULLABLE = 'NO' THEN ''
			ELSE 'NULL'
		END			AS ISNULL, 
		EXTRA as OPTIONS, 
		case when EXTRA = 'auto_increment' then 'Y' 
			else 'N'
		end			as ISAUTO,
		COLUMN_DEFAULT,
		CASE 
			WHEN COLUMN_KEY = 'PRI' THEN 'PK'
			ELSE ''
		END		as PK,
		
		''		as UQ,
		''		as C
from
	`information_schema`.`COLUMNS` A
where 
	table_schema = '{$param['schema']}'
	and table_name = '{$param['object']}'
order by 
	ORDINAL_POSITION
";

return $sql;
?>